/* Includes ---------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "mf_config.h"
#include "uart.h"
#include "lptim.h"
#include "soft_spi.h"
#include "DAC_SGM5353.h"
#include "Hart_5700ACPZ_RL7.h"
/* USER CODE END Includes */

/* Types ------------------------------------------------------------*/
/* USER CODE BEGIN Types */

/* USER CODE END Types */

/* Constants --------------------------------------------------------*/
/* USER CODE BEGIN Constants */

/* USER CODE END Constants */

/* Macro ------------------------------------------------------------*/
/* USER CODE BEGIN Macro */

/* USER CODE END Macro */

/* Variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */

/* Function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FP */

/* USER CODE END FP */

/**
  * @brief  Clock Initialization.
  * @retval None
  */
void MF_Clock_Init(void)
{
    FL_CMU_XTHF_WriteDriverStrength(0x0A);
    FL_CMU_XTHF_Enable();
    FL_DelayMs(2);
    /* Initial RCHF */
    FL_CMU_RCHF_SetFrequency(FL_CMU_RCHF_FREQUENCY_8MHZ);
    FL_CMU_RCHF_Enable();

    /* Initial System Clock */
    FL_FLASH_SetReadWait(FLASH, FL_FLASH_READ_WAIT_0CYCLE);
#if(SystemClock == CLK_SOURCE_RCLP_32K)
    FL_CMU_SetSystemClockSource(FL_CMU_SYSTEM_CLK_SOURCE_RCLP);
    FL_CMU_SetAHBPrescaler(FL_CMU_AHBCLK_PSC_DIV1);
    FL_CMU_SetAPBPrescaler(FL_CMU_APBCLK_PSC_DIV1);
#elif(SystemClock == CLK_SOURCE_XTHF_1MHz)
	FL_CMU_SetSystemClockSource(FL_CMU_SYSTEM_CLK_SOURCE_XTHF);
    FL_CMU_SetAHBPrescaler(FL_CMU_AHBCLK_PSC_DIV8);
    FL_CMU_SetAPBPrescaler(FL_CMU_APBCLK_PSC_DIV1);
#endif

    SystemCoreClockUpdate();
}

void MF_Config_Init(void)
{
	vUART0Init();
	vUART4Init();
	vLPTIMInit();
	vSoftSPIInit();
	vDACSGM5353Init();
	vHart5700ACPZRL7Init();
}

